package ui;

import org.newdawn.slick.Color;
import org.newdawn.slick.Graphics;

import util.Rect;
import util.Settings;

/**
 * Custom button class.
 * @author VincentLy
 */
public class CustomButton extends Rect{

	private String text;
	private boolean on;
	private char name;

	public CustomButton(float x,float y,String s,char c){
		super(x,y,Settings.buttonX,Settings.buttonY,6);		
		text = s;		
		on = false;
		name = c;
	}

	/**
	 * @return button text
	 * @author VincentLy
	 */
	public String text(){return text;}

	/**
	 * @return if hovered over
	 * @author VincentLy
	 */
	public boolean on(){return on;}

	/**
	 * @return reference character
	 * @author VincentLy
	 */
	public char name(){return name;}

	/**
	 * @param b - if hovering over the button
	 * @author VincentLy
	 */
	public void setOn(boolean b){on = b;}
	
	/**
	 * Draws the button.
	 * @author VincentLy
	 */
	public void draw(Graphics g){
		g.setColor(color());
		g.fill(this);
		if(on)
			g.setLineWidth(3);
		g.setColor(Color.white);
		g.draw(this);
		g.drawString(text,left()+(width()-g.getFont().getWidth(text))/2,top()+(height()-g.getFont().getHeight(text))/2);
	}
}